{% extends 'base.html' %}

{% block title %}
    在线博客平台.写博客
{% endblock %}

{% block css %}
<link rel="stylesheet" type="text/css" href="/static/editor/css/editormd.css"/>
<script src="/static/editor/editormd.js" type="text/javascript"></script>
{% endblock %}

{% block content %}
    <div class="main">
        <form action="/blog/update/0" class="layui-form" method="post">
            <input hidden type="text" name="id" value="{{ blog.id }}">
            <div class="layui-form-item">
                <label class="layui-form-label">标   题</label>
                <div class="layui-input-block">
                    <input type="text" name="title" lay-verify="required" placeholder="请输入标题" class="layui-input" value="{{ blog.title }}">
                </div>
            </div>
            <div id="editormd">
                <textarea name = "text" lay-verify="required" style="display:none;" >{{ blog.text }}</textarea>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" style="width: 150px" lay-submit lay-filter="formDemo">保存</button>
                </div>
            </div>
        </form>
    </div>

    <script type="text/javascript">
        layui.use('form', function(){
            var form = layui.form;
            form.on('submit(formDemo)', function(data){
            });
        });

        $(function() {
            editormd("editormd", {
                width: "100%",
                height: 600,
                syncScrolling: "single",
                path: "/static/editor/lib/", //依赖lib文件夹路径
                emoji: true,
                taskList: true,
                tocm: true,
                imageUpload: true,	//开启本地图片上传
                imageFormats: ["jpg", "jpeg", "gif", "png"],	//设置上传图片的格式
                imageUploadURL: "/blog/imgUpload"		//上传图片请求路径
            });
        });
    </script>
{% endblock %}

